#!/bin/bash
echo "get nacos config ..."
export INSTALL_HOME=$(cd `dirname $0`; pwd)

NACOS_ADDRESS=${NACOS_ADDRESS:-"console.nacos.io"}
NACOS_DATA_ID=${NACOS_DATA_ID:-"application-test"}
NACOS_GROUP=${NACOS_GROUP:-"qvz24jml.oxs.xaliyun.com"}
while true
do
echo "start..."
NACOS_HTTP_STATUS=$(curl -X GET -m 10 -o out.response -s -w %{http_code} http://${NACOS_ADDRESS}/nacos/v1/cs/configs?dataId=${NACOS_DATA_ID}\&group=${NACOS_GROUP})
echo "NACOS_HTTP_STATUS...$NACOS_HTTP_STATUS"
if [ -n "$NACOS_HTTP_STATUS" -a "$NACOS_HTTP_STATUS" != "200" ]; then
    echo "call NACOS failed..." > 1
	exit 1
fi
mv out.response /usr/share/nginx/html/config.json
echo "sleep 10 second..."
sleep 10
done
